package nexbit.icons.moonshine;

/**
 * Created by aless_000 on 1/2/2015.
 */
import android.app.Activity;
import android.content.res.TypedArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class NavListItem extends ArrayAdapter<String>{
    private Activity mContext;
    private String[] mTitles;
    private TypedArray mImages;

    public NavListItem(Activity context,String[] titles, TypedArray images) {
        super(context, R.layout.nav_list_item, titles);
        this.mContext = context;
        this.mTitles = titles;
        this.mImages = images;
    }
    @Override
    public View getView(int position, View view, ViewGroup parent) {
        LayoutInflater inflater = mContext.getLayoutInflater();

        // get views from id for entering data
        View rowView = inflater.inflate(R.layout.nav_list_item, null, true);
        TextView txtTitle = (TextView) rowView.findViewById(R.id.nav_list_text);
        ImageView imageView = (ImageView) rowView.findViewById(R.id.nav_list_image);

        // set data for titles and images
        txtTitle.setText(mTitles[position]);
        imageView.setImageDrawable(mImages.getDrawable(position));

        return rowView;
    }
}